package com.cos.lession59.web.controller;

import com.cos.lession59.entity.User;
import org.springframework.web.bind.annotation.*;

/**
 * @author: COS
 * @time: 2021/11/18 9:38
 * @description:
 */
@RestController
@RequestMapping("/userSys")
//@CrossOrigin("http://localhost:8081")
//@CrossOrigin({"http://localhost:8081","http://localhost:8082"})
public class UserController {

    //@RequestMapping(value = "/user",method = RequestMethod.GET)
    @GetMapping("/user")
    public String getAllUser(){
        System.out.println("getAllUser");
        return "这个是getAllUser";
    }
   // @RequestMapping(value = "/user",method = RequestMethod.POST)
    @PostMapping("/user")
//    @CrossOrigin("http://localhost:8081")
    public String addUser(){
        System.out.println("addUser");
        return "这个是addUser";
    }

    @GetMapping("/user/{name}")
    public User getUserByName(@PathVariable("name") String name){
        System.out.println("getUserByName:"+name);
        return new User(1, "zs", "男");
    }

    @PutMapping("/user")
    public String updateUser(@RequestBody User user){
        System.out.println("updateUser:"+user);
        return "ok";
    }
    @DeleteMapping("/user/{uno}")
    public String delUser(@PathVariable("uno") int uno){
        System.out.println("delUser:"+uno);
        return "ok";
    }


}
